package cc.comac.mom.datahandlers.entity;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import cc.comac.mom.bean.QualityAsrCheckFormDetailDeleteHistory;
import cc.comac.mom.bean.base.LimitPageBean;
import cc.comac.mom.dao.entity.QualityAsrCheckFormDetailDeleteHistoryDao;
import cc.comac.mom.entity.QualityAsrCheckFormDetailDeleteHistoryEntity;
import cc.comac.mom.util.ResultBean;
@Component
@Transactional
public class QualityAsrCheckFormDetailDeleteHistoryDataHandler extends ServiceImpl<QualityAsrCheckFormDetailDeleteHistoryDao, QualityAsrCheckFormDetailDeleteHistoryEntity>{

	@Autowired
	private QualityAsrCheckFormDetailDeleteHistoryDao qualityAsrCheckFormDetailDeleteHistoryDao;
	
	public ResultBean selectBySomeFeilds (QualityAsrCheckFormDetailDeleteHistory qualityAsrCheckFormDetailDeleteHistory) {
		ResultBean resultBean = new ResultBean(true);
		if (qualityAsrCheckFormDetailDeleteHistory.getPageNum() == 0) {
			qualityAsrCheckFormDetailDeleteHistory.setPageNum(1);
		}
		if (qualityAsrCheckFormDetailDeleteHistory.getPageSize() == 0) {
			qualityAsrCheckFormDetailDeleteHistory.setPageSize(10);
		}
		int pageNum = qualityAsrCheckFormDetailDeleteHistory.getPageNum();
		qualityAsrCheckFormDetailDeleteHistory.setPageNum((qualityAsrCheckFormDetailDeleteHistory.getPageNum()-1)*qualityAsrCheckFormDetailDeleteHistory.getPageSize());
		// 分页查询所需数据
		List<QualityAsrCheckFormDetailDeleteHistory> selectBySomeFeilds = qualityAsrCheckFormDetailDeleteHistoryDao.selectBySomeFields(qualityAsrCheckFormDetailDeleteHistory);
		int selectCountBySomeFields = qualityAsrCheckFormDetailDeleteHistoryDao.selectCountBySomeFields();
		LimitPageBean<QualityAsrCheckFormDetailDeleteHistory> limitPageBean = new LimitPageBean<QualityAsrCheckFormDetailDeleteHistory>();
		limitPageBean.setEntityList(selectBySomeFeilds);
		limitPageBean.setPageNum(pageNum);
		limitPageBean.setPageCount((int) Math.ceil(selectCountBySomeFields * 1.0d / qualityAsrCheckFormDetailDeleteHistory.getPageSize()));
		limitPageBean.setPageSize(qualityAsrCheckFormDetailDeleteHistory.getPageSize());
		limitPageBean.setTotalQuantity(selectCountBySomeFields);
		resultBean.setObject(limitPageBean);
		return resultBean;
	}
}
